#include <bits/stdc++.h>

using namespace std;

int main() {
	int a, b, c;
	scanf("%02d/%02d/%02d", &a, &b, &c);
	for (int i = 1960; i < 2060; i++) {
		for (int j = 1 ; j < 13; j++ ) {
			for (int k = 1 ; k <= 31 ; k++) {
				if (j == 4 || j == 6 || j == 9 || j == 11 ) {
					if (k > 30)break;
				}
				if (j == 2) {
					if ((i % 100 != 0 && i % 4 == 0) || i % 400 == 0) {
						if (k > 29)break;
					} else {
						if (k > 28)break;
					}
				}
				if ((i % 100 == a && j == b && k == c) ||
				        (i % 100 == c && j == a && k == b) ||
				        (i % 100 == c && j == b && k == a)) {
					printf("%04d-%02d-%02d\n", i, j, k);
				}
			}
		}
	}
	return 0;
}
